#pragma once

#include "ItemProvider.h"
#include <map>

namespace Explorer
{
    class DirConsumer : public ItemConsumer
    {
    public:
        typedef TestFramework::TestVector<const Item*> Items;

        virtual void Consume(const Item& item)
        {
            Result.PushBack(&item);
        }

        Items& GetResult()
        {
            return Result;
        }

    private:
        Items Result;
    };

    class Console
    {
    public:
        Console(const ItemProvider& provider, const Item& item);
        void ProcessInput(const TestFramework::TestString& input);

    private:
        void ShowHelp();
        void Dir();
        void Cd();
        void ShowChilds();

    private:
        const ItemProvider& Root;
        const Item& RootItem;
        const Item* CurrentItem;
        typedef std::map<TestFramework::TestString, void (Console::*)()> CommandsMap;
        CommandsMap Commands;
        DirConsumer::Items Children;
        TestFramework::TestString RequestParams;
    };
}
